package com.wmx.test;

import org.apache.rocketmq.client.producer.DefaultMQProducer;
import org.apache.rocketmq.client.producer.SendResult;
import org.apache.rocketmq.common.message.Message;
import org.apache.rocketmq.remoting.common.RemotingHelper;

public class SyncProducer {
    public static void main(String[] args) throws Exception {
        DefaultMQProducer producer = new DefaultMQProducer("wsGroup");
        producer.setNamesrvAddr("192.168.19.130:9877");


        producer.start();
        for(int i = 0; i <5; i++) {
            Message msg = new Message("broker-a" /* Topic */,
                    "test" /* Tag */,
                    "wumengxin".getBytes(RemotingHelper.DEFAULT_CHARSET) /* Message body */
            );
            SendResult sendResult = producer.send(msg);
            System.out.printf("=========发送结果===============", sendResult);
            System.out.printf("%s%n", "end line");


        }

        producer.shutdown();
    }


}
